<?php defined('SYSPATH') or die('No direct script access.');

// Категории
class Controller_Ajax_Categories extends Controller_Base
{	
	public function action_get_category()
	{
        if($this->request->is_ajax())
        {
            $category_id = $this->request->post('category_id');
            
            $category = $this->category_model->get_category($category_id);
            
            $result = array(
                'success'  => true,
                'category' => $category
            );
            
            header('Content-type: text/json');
            echo json_encode($result);
        }
        die();
	}
    
    public function action_get_subcategory()
    {
        if($this->request->is_ajax())
        {
            $subcategory_id = $this->request->post('subcategory_id');
            
            $subcategory = $this->category_model->get_subcategory($subcategory_id);
            
            $result = array(
                'success'     => true,
                'subcategory' => $subcategory
            );
            
            header('Content-type: text/json');
            echo json_encode($result);
        }
        die();
    }

} // End Ajax_Categories
